# Maintainer: Bruno Pagani <archange@archlinux.org>

_pkg=QDarkStyle
pkgname=python-${_pkg,,}
pkgver=3.1
pkgrel=2
pkgdesc="Dark style sheet for QtWidgets application"
arch=(any)
url="https://github.com/ColinDuquesnoy/QDarkStyleSheet"
license=(MIT CCPL)
depends=(python-helpdev python-qtpy)
makedepends=(python-setuptools)
checkdepends=(python-pyqt5 pyside2 python-pytest python-pytest-qt)
# Pypi tarballs do not provide tests files anymore
#source=(https://files.pythonhosted.org/packages/source/${_pkg::1}/${_pkg}/${_pkg}-${pkgver}.tar.gz)
source=(${url}/archive/v${pkgver}/${pkgname}-${pkgver}.tar.gz)
sha256sums=('ce22fb44a8115bad4b0ae409688568cccbee99fe3d284407719c899c360bcf2e')

build() {
  cd ${_pkg}Sheet-${pkgver}
  python setup.py build
}

check() {
  cd ${_pkg}Sheet-${pkgver}
  # PyQt5 tests
  python -m qdarkstyle.example --qt_from=pyqt5 --test --offscreen
  # PySide2 tests, https://github.com/ColinDuquesnoy/QDarkStyleSheet/issues/275
  sed -i 's|dw_buttons.checkBoxTristate.setCheckState(1)|dw_buttons.checkBoxTristate.setCheckState(QtCore.Qt.Unchecked)|' qdarkstyle/example/__main__.py
  python -m qdarkstyle.example --qt_from=pyside2 --test --offscreen
}

package() {
  cd ${_pkg}Sheet-${pkgver}
  python setup.py install --prefix=/usr --root="${pkgdir}" --skip-build --optimize=1
  install -Dm644 LICENSE.rst -t "${pkgdir}"/usr/share/licenses/${pkgname}
}
